#include "head.h"

int main(int argc, char const *argv[])
{
    int fd= open("test.txt" , O_WRONLY | O_CREAT, 0666 );
    if ( EOF == fd )
    {
       perror("open error");
       return -1;
    }
    
    int i=10;
    char buf='A';
    flock(fd,LOCK_EX);
    while (i--)
    {
        write( fd, &buf , sizeof(buf) );
        sleep(1);
    }
    

    flock(fd,LOCK_UN);
    close(fd);


    return 0;
}
